﻿using System.Collections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Marbles.Core.Helpers
{
    public class Text
    {

        public List<string> GetWordList(string text)
        {
            List<string> items = new List<string>();
            MatchCollection matchs = Regex.Matches(text, "(?<word>\\b\\w+\\b)(?!.+\\b\\k<word>\\b)", RegexOptions.IgnoreCase | RegexOptions.Multiline);


            foreach (Match m in matchs)
            {
                if (m.Groups["word"] != null)
                {
                    if (m.Groups["word"].Value != string.Empty)
                    {
                        if (!items.Contains(m.Groups["word"].Value.Trim())) { items.Add(m.Groups["word"].Value.Trim()); }
                    }
                }
            }

            return items;
        }
    }
}
